package gsm.cable.client;

import gsm.cable.client.view.AdminWidget;
import gsm.cable.client.view.UserWidget;
import gsm.cable.client.view.Test;
import gsm.cable.client.view.ViewWidget;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class CableGwt implements EntryPoint {
	private String VIEW_CONTAINER_ID = "viewcontainer";

	@Override
	public void onModuleLoad() {
		// Test test = new Test("shakti");
//		testAdminWidget();
		testUserWidget();
		// testMenuBar();
	}

	private void testUserWidget() {
		RootPanel simplePanel = RootPanel.get(VIEW_CONTAINER_ID);
		UserWidget userWidget = new UserWidget();
		simplePanel.add(userWidget);
	}

	private void testAdminWidget() {
		RootPanel simplePanel = RootPanel.get(VIEW_CONTAINER_ID);
		AdminWidget adminWidget = new AdminWidget();
		simplePanel.add(adminWidget);
	}

	private void testViewWidget() {
		RootPanel simplePanel = RootPanel.get(VIEW_CONTAINER_ID);
		ViewWidget viewWidget = new ViewWidget();
		simplePanel.add(viewWidget);
	}

	private void testMenuBar() {
		MenuBar menuBar = new MenuBar();
		MenuBar menuBar1 = new MenuBar(true);
		MenuItem item1 = new MenuItem("item1", menuBar1);
		MenuItem item2 = new MenuItem("item1", new CommandImpl("item2"));
		MenuItem item3 = new MenuItem("item1", new CommandImpl("item3"));
		MenuItem item4 = new MenuItem("item1", new CommandImpl("item4"));
		menuBar.addItem(item1);
		menuBar1.addItem(item2);
		menuBar1.addItem(item3);
		menuBar1.addItem(item4);
		RootPanel.get(VIEW_CONTAINER_ID).add(menuBar);

	}

	private class CommandImpl implements Command {

		private String itemStr;

		public CommandImpl(String itemStr) {
			this.itemStr = itemStr;
		}

		@Override
		public void execute() {

			Window.alert(itemStr);

		}

	}
}
